var dg_role_accredit = $('#dg_role_accredit');
var dg_user_accredit = $('#dg_user_accredit');
var dg_menu_accredit = $('#dg_menu_accredit');
var currentRoleId = null;
$(function () {
    dg_role_accredit.datagrid({
                                  url: ctx + '/sys/role/search',
                                  method: 'get',
                                  onSelect: function (index,row) {
                                      currentRoleId = row.id;
                                      dg_user_accredit.datagrid({
                                                                    url:ctx+'/sys/user/search?roleId='+currentRoleId,
                                                                    method:'get'
                                                                })
                                      dg_menu_accredit.treegrid({
                                                                    url:ctx+'/sys/menu/tree_data?roleId='+currentRoleId,
                                                                    method:'get',
                                                                    idField: 'id',
                                                                    treeField: 'name'
                                                                })
                                  }
                              });

})